package cn.niit.cn.niit.controller;

import cn.niit.cn.niit.entity.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.Mapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

@org.springframework.stereotype.Controller
public class Controller {

    @GetMapping ("/login")
    public String login(){
        return "login";
    }
    @PostMapping("/login")
    public String toLogin(String username,String password){
        System.out.println("用户的账号 " +username + "密码 " + password);
        User mysqlUser = new User(username);
        System.out.println("mysql" + mysqlUser);
        if(!password.equals(mysqlUser.getPassword())){
            return "login";
        }
        return "index";
    }

    @RequestMapping(value="/index")
   public String index(){

       return "index";
   }
    @RequestMapping(value="/list")
    public String list(){

        return "list";
    }
    @RequestMapping(value="/add")
    public String add(){

        return "add";
    }
}
